package com.dmzc.stage1.chapter3;

import java.util.concurrent.TimeUnit;

public class ThreadSleep {
    public static void main(String[] args) {
        new Thread(() -> {
            try {
                long startTime = System.currentTimeMillis();
                TimeUnit.SECONDS.sleep(2);
                long endTime = System.currentTimeMillis();
                System.out.println(endTime - startTime);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }).start();

        try {
            long startTime = System.currentTimeMillis();
            TimeUnit.SECONDS.sleep(3);
            long endTime = System.currentTimeMillis();
            System.out.println(endTime - startTime);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
